package net.display;

import javax.servlet.http.HttpServletRequest;

import net.bo.KUtilisateur;
import net.ko.controller.KObjectController;
import net.ko.displays.KObjectDisplay;
import net.ko.http.views.KobjectHttpAbstractView;
import net.ko.kobject.KObject;

public class DisplayParameterAccount extends KObjectDisplay {

	@Override
	public void afterLoading(KObject ko, KobjectHttpAbstractView view,
			HttpServletRequest request) {
		try {
			KUtilisateur user = (KUtilisateur) request.getSession().getAttribute("activeUser");
			ko.copyFrom(user);
			ko.setId(user.getId());
		} catch (SecurityException | IllegalArgumentException
				| NoSuchFieldException | IllegalAccessException e) {
			e.printStackTrace();
		}
		super.afterLoading(ko, view, request);
	}

	@Override
	public KObjectController getKobjectController(KObjectController koc, HttpServletRequest request) {
		koc.setValidatorClassName("net.controller.KValidateParams");
		koc.getFieldController("login").setValidateMethodName("validateLogin");
		koc.getFieldController("mail").setValidateMethodName("validateEmail");

		koc.getFieldController("login").setOptions("style='width:47%;'");
		koc.getFieldController("mail").setOptions("style='width:100%;'");
		return super.getKobjectController(koc, request);
	}

}
